<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\User;
class Collect extends Model
{
    use SoftDeletes;
    protected $table = 'collect';
    public function getCollectUser($id){

        $collects = $this->where('course_class_id',$id)->select('id','user_id')->get();
        $userArr = [];
        foreach($collects as $collect){
            $userArr[] = $collect->user_id;
        }
        $users = User::whereIn('id',$userArr)->select('openid','id')->get();
        return $users;
    }

    public function user(){
        return $this->belongsTo('App\User','user_id','id');
    }
}
